using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;

namespace PloxEdApp
{
    public partial class PloxSet : Form
    {
        PloxEd parent; //I need to be passed an instance of my parent window so I can get and set the timer.

        public PloxSet(PloxEd myParent)
        {
            this.parent = myParent;

            InitializeComponent();

            this.timerIntervalUpDown.Maximum = UInt16.MaxValue;
            this.logFileDialog.InitialDirectory = Environment.SystemDirectory;
            this.logPathBox.BackColor = SystemColors.Window; //Prevent it from graying out.

            this.timerIntervalUpDown.Value = (decimal)myParent.timerInterval;
            this.logToEventLogCheckBox.Checked = myParent.logToEventLog;
            this.logToFlatFileCheckBox.Checked = myParent.logToFlatFile;
            this.logPathBox.Text = myParent.logFile;
            this.logOnLocalEnumFailCheckBox.Checked = myParent.logOnLocalEnumFail;
            this.logOnLocalDelFailCheckBox.Checked = myParent.logOnLocalDelFail;
            this.logOnFtpErrorCheckBox.Checked = myParent.logOnFTPError;
            this.redactFTPCredentialsCheckBox.Checked = myParent.redactFTPCredentials;
            this.haltOnDirDelFailCheckBox.Checked = myParent.haltOnDirDelFail;
            this.haltOnFileDelFailCheckBox.Checked = myParent.haltOnFileDelFail;
        }

        private void okButton_Click(object sender, EventArgs e)
        {
            this.parent.timerInterval = (double)this.timerIntervalUpDown.Value;
            this.parent.logToEventLog = this.logToEventLogCheckBox.Checked;
            this.parent.logToFlatFile = this.logToFlatFileCheckBox.Checked;
            this.parent.logFile = this.logPathBox.Text;
            this.parent.logOnLocalEnumFail = this.logOnLocalEnumFailCheckBox.Checked;
            this.parent.logOnLocalDelFail = this.logOnLocalDelFailCheckBox.Checked;
            this.parent.logOnFTPError = this.logOnFtpErrorCheckBox.Checked;
            this.parent.redactFTPCredentials = this.redactFTPCredentialsCheckBox.Checked;
            this.parent.haltOnDirDelFail = this.haltOnDirDelFailCheckBox.Checked;
            this.parent.haltOnFileDelFail = this.haltOnFileDelFailCheckBox.Checked;

            DialogResult = DialogResult.OK;
        }

        private void cancelButton_Click(object sender, EventArgs e)
        {
            DialogResult = DialogResult.Cancel;
        }

        private void browseButton_Click(object sender, EventArgs e)
        {
            if (logFileDialog.ShowDialog(this).Equals(DialogResult.OK))
                this.logPathBox.Text = logFileDialog.FileName;
        }
    }
}